Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : Sheet8 * File : src/app/(site)/topics/[slug]/page.tsx9 * Module : app10 * Repository : https://git.spboucher.ai/sheet11 * Project Website : https://sheet.spboucher.ai12 * Created : 2026-11-1713 * Last Modified : 2026-11-1714 *15 * Author : Simon-Pierre Boucher16 * Position : Professor of Finance17 * Institution : Université du Québec en Outaouais (UQO)18 * Organization : SP Boucher19 * Website : https://spboucher.ai20 * Git : https://git.spboucher.ai21 *22 * Preferred Contact: contact@spboucher.ai23 * Development : dev@spboucher.ai24 * Support : support@spboucher.ai25 * Security/Admin : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243import type { Metadata } from "next";44import Link from "next/link";45import { notFound } from "next/navigation";46import { getLocale } from "@/i18n/server";47import { dict, fill } from "@/i18n/dict";48import { listPublished, listTopics } from "@/server/sheets";49import { SheetGrid } from "@/components/site/sheet-card";5051export const dynamic = "force-dynamic";52const T = dict({ all: ["Tous les thèmes", "All topics"], count: ["{n} fiche(s)", "{n} sheet(s)"] });53const find = async (slug: string, locale: "fr" | "en") => (/^[a-z0-9-]{1,96}$/.test(slug) ? (await listTopics(locale)).find((x) => x.slug === slug) : undefined);5455export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise<Metadata> {56 const { slug } = await params; const tp = await find(slug, await getLocale());57 return tp ? { title: tp.name, description: tp.description || undefined, alternates: { canonical: `/topics/${tp.slug}` } } : { robots: { index: false } };58}5960export default async function Topic({ params }: { params: Promise<{ slug: string }> }) {61 const { slug } = await params; const locale = await getLocale(); const t = T(locale);62 const tp = await find(slug, locale);63 if (!tp) notFound();64 const sheets = await listPublished({ topic: tp.slug, limit: 48, offset: 0, uiLocale: locale });65 return (66 <div className="mx-auto max-w-[1240px] pt-8 safe-x">67 <Link href="/topics" className="inline-flex min-h-11 items-center text-sm font-semibold text-accent">← {t.all}</Link>68 <h1 className="mt-2 font-display text-4xl font-semibold tracking-tight sm:text-5xl">{tp.name}</h1>69 {tp.description && <p className="mt-3 max-w-[70ch] text-lg text-muted">{tp.description}</p>}70 <p className="mt-2 text-sm text-faint">{fill(t.count, { n: sheets.total })}</p>71 <h2 className="sr-only">{fill(t.count, { n: sheets.total })}</h2>72 <div className="mt-8"><SheetGrid sheets={sheets.items} locale={locale} /></div>73 </div>74 );75}76